/* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.flowable.dmn.xml;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.flowable.dmn.converter.child.OutputValuesParser;
import org.junit.jupiter.api.Test;

public class OutputValuesParserTest {

    private static String LIST_OUTPUT_VALUES_NUMBER = "10,20,30, 40, 50, 60";
    private static String LIST_OUTPUT_VALUES = "\"DECLINE\",\"REFER\",\"ACCEPT\", \"DECLINE\", \"REFER\", \"ACCEPT\",\"DECLINE\",\"RE,FER\", \"ACCE,PT\"";
    private static String LONG_LIST_OUTPUT_VALUES =
            """
                    "bow","he,llo","a, te", "sta, rt","creature","shade","poem","eat","swam","aloud","possibly","stay","repeat","record","cream","pole","guard","soon","gas","state","wheel","problem","fish","thread","base","baby","steel","structure","progress","driven","breath","image","activity","father","wind","dried","finger","conversation","village","luck","said","important","related","arrangement","effort","count","extra","flat","broke","atmosphere","agree","vapor","these","guess","group","bottom","take","back","involved","rear","steam","forget","they","whenever","grandmother","medicine","real","picture","exciting","mirror","quite","primitive","having","dark","wide","cost","clay","captain","party","colony","upon","surrounded","rich","scared","operation","only","west","left","waste","took","replied","charge","fog","fight","excited","forgotten","due","apart","ride","fourth","vegetable","blew","peace","table","available","blind","piano","struck","hurry","lamp","low","figure","leave","title","limited","neck","plenty","bread","tall","hat","chart","mountain","swim","consider","shop","upper","lucky","vertical","nodded","taken","girl","vowel","aware","held","able","probably","let","word","serve","previous","curious","are","gently","leader","poor","bound","main","country","before","apartment","women","camp","yesterday","pattern","claws","chair","fuel","continent","birth","neighborhood","particular","sit","suddenly","shirt","review","happy","pipe","system","pocket","theory","education","smell","identity","crack","water","fell","sign","twelve","universe","composed","unless","lonely","younger","headed","cause","once","dress","river","pain","therefore","herself","then","stared"
                    "catch","driver","extra","ago","common","lungs","length","paint","space","direct","brief","whispered","water","produce","including","image","string","greatest","smallest","arrangement","using","daughter","gradually","remarkable","damage","gold","search","cat","highest","connected","stopped","anybody","western","process","brave","coffee","cap","growth","having","picture","pencil","thin","skin","wire","apart","news","faster","climate","nervous","gasoline","nervous","meat","put","putting","cent","faster","coming","dangerous","with","death","white","society","support","oldest","worker","company","other","lovely","hardly","fifth","doubt","exchange","behavior","glass","given","cost","lay","movie","dried","talk","younger","tribe","station","strike","plane","heard","shown","wool","but","value","combination","mice","together","driven","complete","compound","kids","product","curve","mind","front","shall","film","pull","shallow","death","lift","news","country","pine","teach","gently","maybe","somehow","break","student","principal","neighbor","freedom","four","suggest","tropical","her","western","police","pencil","transportation","chapter","class","threw","refused","proud","farther","molecular","catch","scientist","tax","transportation","mind","seems","then","church","nor","ate","seems","taste","ran","scientist","group","eye","own","hundred","section","hill","swung","universe","steam","thy","bee","gasoline","mood","goes","congress","far","strike","flies","experiment","captain","wrapped","trunk","particularly","couple","afraid","seldom","swam","principal","caught","spell","rough","fewer","could","known","poem","pitch","mostly","has","bit","gently","beyond","roof","make","helpful","immediately"
                    "herself","third","all","aware","key","minute","check","mathematics","seat","colony","when","direct","forest","merely","instance","excellent","living","entire","sun","partly","desk","smoke","explanation","hope","chosen","date","slipped","they","article","pupil","labor","him","horse","energy","support","coast","stuck","plain","label","remove","very","percent","figure","individual","type","globe","likely","known","tobacco","serve","equal","in","send","supper","passage","got","age","hard","sink","memory","suggest","sweet","careful","surrounded","actually","inside","well","up","peace","glad","riding","fox","book","nearby","partly","question","mainly","safe","development","image","began","maybe","rhyme","condition","surprise","wheat","climb","electricity","equally","process","read","use","deal","agree","season","attached","enter","correct","hit","origin","far","hole","human","take","ice","rather","someone","surrounded","mistake","it","attack","weight","sudden","breeze","degree","song","might","pattern","felt","chemical","two","cell","stone","prize","blue","crack","husband","factor","respect","dog","season","automobile","still","fix","ate","piece","road","ear","success","college","gentle","younger","excellent","old","worker","own","coal","southern","remove","seed","ever","soft","common","orange","including","lift","with","throughout","ocean","blood","writer","purpose","large","satellites","spell","start","movement","slip","blank","widely","neighborhood","case","sell","silent","sleep","along","reader","run","bat","dry","oil","hungry","bat","green","consider","strange","upon","hardly","fewer","best","while","garden","is"
                    "happily","related","except","biggest","map","moon","fox","pain","war","title","general","quietly","gentle","tropical","drive","pan","forgot","heat","directly","especially","health","sweet","this","around","joy","stems","lucky","complete","must","mixture","compass","neck","corn","harbor","know","onlinetools","thy","tribe","young","negative","loud","happily","rabbit","lower","evening","tribe","differ","want","arrangement","wooden","satisfied","here","amount","driving","replace","cabin","library","third","nuts","putting","darkness","that","death","steady","forty","pilot","canal","prize","some","guard","since","surprise","foreign","chosen","still","traffic","sudden","answer","fort","free","captain","replace","passage","are","life","running","brought","unusual","once","sitting","tired","song","wall","football","worse","take","property","thrown","quick","not","left","table","industry","phrase","close","bite","stop","gift","tower","throat","twelve","rear","clearly","off","vowel","deep","loss","establish","offer","potatoes","image","upper","applied","additional","burn","bound","wet","character","easily","arrive","yard","member","luck","lesson","weight","further","hand","gift","orbit","keep","current","motor","present","born","may","easy","tape","facing","ask","arm","science","bring","clearly","ants","string","kind","beat","full","life","is","stronger","would","calm","tide","surprise","stairs","sense","creature","leaving","spend","human","mixture","graph","topic","magnet","mine","fat","victory","roof","melted","children","right","of","begun","production","directly","said","rose","atomic","previous","house","spin","grew"
                    "work","weather","ordinary","affect","face","last","began","lot","buy","diagram","am","can","cave","parts","remove","leaf","compare","fastened","political","locate","monkey","gulf","during","sets","pine","composition","ill","black","judge","sand","report","reach","system","doll","means","roll","scene","clothing","piano","printed","until","write","fill","sink","our","chapter","sat","massage","someone","society","greatest","ought","than","stiff","whatever","shut","pleasant","green","tape","born","mysterious","star","everywhere","attack","window","log","breathe","solar","thou","known","show","national","weak","massage","away","balance","yes","meat","was","later","turn","brain","wood","regular","prize","mean","those","stranger","younger","sand","central","perfectly","result","surrounded","blew","outer","naturally","rocky","organized","fly","century","audience","past","plus","took","clock","dozen","increase","running","port","said","season","child","class","arrow","yet","bigger","result","actual","master","coal","accident","slabs","up","relationship","sheep","shout","path","shaking","gradually","several","capital","person","apple","completely","deer","railroad","yard","present","push","fat","troops","control","ring","service","honor","closely","occasionally","forgotten","policeman","but","successful","society","goes","shells","studying","solution","pair","third","skill","foot","show","it","get","alphabet","planet","swim","rising","honor","pencil","cat","slept","perfectly","sheet","mother","correct","tape","sheet","sold","region","cut","tool","raw","hurry","longer","group","human","everyone","like","about","yard","position","wait"
                    "church","unless","cause","pie","four","modern","vast","he","forget","stood","powerful","noted","anything","can","fur","direction","map","week","given","shake","say","voice","colony","rope","eye","bat","simplest","community","plus","structure","machinery","color","palace","matter","station","all","satellites","nature","deal","husband","lamp","characteristic","principal","slave","snow","afraid","additional","slabs","individual","grandmother","thread","term","think","disease","review","touch","signal","settle","hungry","parts","chance","frozen","art","moving","hurried","wash","affect","piano","teeth","trouble","dead","combination","parts","require","morning","colony","belt","trunk","dish","worth","satellites","plural","whatever","drove","driver","memory","me","silver","rapidly","torn","by","solution","longer","massage","mail","lower","sleep","me","nearly","escape","gold","lose","sheet","cloth","climb","ran","find","taste","torn","yesterday","place","three","shadow","thousand","blood","thrown","interior","earn","crop","known","great","learn","syllable","partly","look","pretty","flat","tax","work","everybody","slow","examine","dog","wooden","brain","probably","brief","building","correctly","terrible","joy","wing","above","nation","poet","dawn","bicycle","selection","orbit","pitch","exact","pet","iron","rich","sun","wave","start","whispered","pain","picture","lovely","married","stretch","your","half","nodded","brief","fifty","right","believed","typical","burst","wall","distant","cup","also","health","massage","wrapped","near","crop","pipe","happened","frequently","dangerous","cannot","about","tired","already","trade","threw","planning","positive"
                    "conversation","shells","vast","hundred","warn","close","state","wooden","gold","grow","hard","excitement","wall","halfway","enough","great","earth","yard","toward","mirror","teeth","horse","detail","through","system","bottle","neighborhood","root","field","element","date","sort","sight","worry","forgot","nature","fellow","announced","knife","soil","dawn","grow","open","enough","how","happened","white","husband","start","mass","escape","drive","roof","control","part","popular","successful","large","cream","go","important","raw","stove","plastic","spider","silent","baseball","surprise","early","show","gone","cent","therefore","mistake","twice","better","clay","possible","spoken","tiny","wherever","coming","report","meal","balloon","frame","red","rhythm","board","firm","lower","arrow","unknown","thousand","plant","equal","atom","needs","sets","ready","border","somebody","brother","brain","knowledge","torn","pure","hand","brave","coach","milk","work","course","explore","fact","duty","bar","think","column","maybe","similar","electricity","hay","curious","similar","special","home","author","power","trick","harder","finger","or","journey","finest","won","appropriate","long","exchange","camera","single","describe","bag","stock","serve","equal","fog","growth","follow","nation","planning","team","no","nearest","tired","flat","anywhere","note","till","opportunity","position","particular","wrong","rice","car","dear","more","write","particular","village","box","growth","afraid","call","many","met","both","picture","week","sea","population","cup","hurried","theory","us","research","development","afraid","ready","excited","desert","tropical","stick"
                    "stood","box","lovely","pupil","gentle","move","create","carry","article","meet","however","express","went","itself","rock","frozen","replace","anyone","group","surrounded","weak","stomach","see","nearest","discover","forth","weight","goose","reason","drive","discussion","look","floor","sometime","life","orange","willing","meal","excitement","good","pleasure","bean","harbor","careful","likely","range","chapter","inside","recognize","might","using","trip","colony","brought","bit","whenever","would","attack","parallel","sometime","dozen","simply","bottom","including","similar","furniture","hospital","extra","straw","rough","young","you","complex","they","only","couple","give","slope","stronger","youth","physical","native","away","grade","cow","highest","could","began","twice","pitch","listen","establish","unhappy","gain","because","alphabet","lack","nice","fire","those","stream","replace","especially","treated","till","whether","pencil","means","cup","map","brain","composition","discussion","principle","spell","wood","move","came","package","laugh","limited","work","motor","paragraph","stock","rule","height","completely","through","having","information","quarter","during","nothing","speech","larger","hall","round","earn","trick","soon","potatoes","interest","military","improve","won","lie","entire","hello","industrial","matter","brave","discussion","care","dead","breathe","were","brown","potatoes","most","income","column","research","office","represent","frozen","scene","cost","bear","tape","maybe","moment","certain","package","driven","plain","though","riding","film","speed","mail","steam","hung","slow","thought","bound","package","influence","boat","tool","chose","teacher","occur"
                    "enough","experience","particularly","lunch","hope","shown","command","expression","except","onto","title","essential","although","machine","pure","save","keep","statement","science","welcome","forth","rising","correctly","base","story","such","habit","improve","idea","food","coming","television","percent","more","fighting","leaf","properly","fruit","band","court","creature","wrote","motion","present","engineer","stronger","parallel","below","wrote","fully","paint","essential","great","greater","major","evening","flame","rocket","air","hung","band","then","bad","test","unit","if","cloud","related","copper","saddle","receive","married","east","string","notice","planned","trap","combine","living","disease","do","grabbed","minerals","me","sick","saw","football","daily","cave","theory","mysterious","held","can","stranger","shut","taught","remain","yellow","today","orbit","mark","build","solid","please","ought","salt","tie","crack","standard","yet","dangerous","its","whether","track","gone","discussion","suggest","conversation","tower","paper","dirt","guide","waste","dangerous","clothes","silence","drop","find","according","hide","particular","dish","form","replied","position","record","share","sudden","develop","since","needle","face","sat","office","prepare","it","cool","realize","uncle","brief","spell","when","higher","time","with","adult","sister","death","here","sat","block","occasionally","stick","topic","involved","aside","passage","wood","his","begun","last","doubt","began","page","buy","pay","attached","would","gentle","changing","car","bet","while","orange","question","straw","airplane","tie","scene","raw","thin","such","citizen"
                    "wild","threw","skill","slide","gradually","rich","public","mass","model","beautiful","fifteen","tall","chain","bus","discussion","cost","mental","important","build","tried","foot","walk","fourth","sand","nest","chamber","cabin","realize","corn","step","coal","independent","desk","closer","sight","stranger","stone","physical","layers","our","who","prize","paragraph","afraid","atomic","movement","lesson","particularly","thousand","proper","heading","good","three","house","any","swing","potatoes","fruit","willing","chemical","government","attached","worried","usually","every","exchange","another","industry","series","pond","being","triangle","lamp","standard","printed","element","old","thou","story","cloud","cross","instead","develop","teeth","equal","loss","concerned","tide","ask","neighborhood","get","from","event","wild","gulf","beneath","selection","husband","adult","greatest","real","college","busy","widely","rice","percent","light","happily","living","them","promised","adult","especially","ten","long","announced","help","pot","thin","pine","monkey","modern","yellow","peace","growth","cream","grandfather","connected","home","noon","tell","arrive","stiff","question","spell","interior","comfortable","valuable","hardly","dirt","back","say","history","brother","wet","carried","softly","scene","nose","graph","higher","nose","volume","certain","heading","forgot","sick","longer","cow","poet","duck","seed","blind","roof","moving","fewer","better","unknown","skin","order","fence","orange","excited","mostly","chief","born","we","again","fence","green","pilot","note","crowd","enter","fierce","ranch","scientist","add","national","various","snake","can","on"
                    "meat","eventually","forget","nine","own","clear","tape","passage","tape","light","company","slope","swing","thread","purple","breeze","snow","same","develop","thy","wrapped","touch","occur","horn","lion","all","eleven","twice","salt","rocky","stone","should","broken","smallest","jack","branch","team","news","torn","sent","gave","instead","cover","moon","ahead","circus","whistle","alive","blow","afraid","wonderful","environment","quickly","continued","best","trace","found","flew","themselves","nor","pack","manufacturing","particular","pick","require","mill","wife","strength","camera","rear","police","slabs","surface","wish","forget","dish","us","else","happy","brief","became","stiff","entire","merely","label","give","boy","subject","compound","make","city","main","realize","add","character","chose","potatoes","has","your","butter","might","must","gently","usual","thank","trouble","keep","matter","material","explore","spell","belong","sold","asleep","real","death","building","image","language","neighborhood","station","asleep","title","closely","numeral","case","sink","passage","journey","lie","easier","case","cup","stock","character","possibly","twice","musical","quarter","rich","height","interior","combine","nobody","setting","breath","heat","slave","pony","life","thrown","listen","heat","trunk","average","border","detail","grown","husband","refused","become","early","changing","division","plastic","gas","cell","middle","pile","rather","fire","trail","spell","anywhere","bar","summer","for","silence","meant","slight","story","cook","new","dried","grade","inside","left","coal","once","enemy","represent","hope","fort"
                    "feature","upon","member","town","rich","catch","struck","shoot","brown","pleasant","theory","fort","consonant","income","shout","describe","figure","planning","year","exclaimed","rod","corn","construction","railroad","tired","knife","settlers","forward","support","level","free","buy","temperature","condition","numeral","sing","heading","may","sky","tobacco","condition","hand","apartment","very","supply","quickly","dropped","perfect","world","eager","salmon","thank","yesterday","leave","medicine","audience","shot","mill","pond","duty","unhappy","season","coat","perhaps","think","job","selection","writer","business","browserling","news","new","obtain","bowl","universe","road","post","silver","sight","correct","live","fight","castle","fighting","split","nails","happily","rest","poetry","or","excellent","science","furniture","hundred","involved","plain","carefully","energy","method","quarter","officer","sound","curious","wonderful","repeat","fur","gold","wonder","tip","national","uncle","mathematics","club","outline","browserling","needle","nobody","size","brush","spread","market","welcome","sheep","volume","if","establish","birds","explain","compass","smoke","fun","spend","base","pink","nation","famous","wonderful","square","pattern","empty","sudden","sail","congress","team","closely","him","is","paragraph","today","clear","hang","is","now","brick","alphabet","identity","browserling","teacher","fallen","certainly","beautiful","finest","speed","height","length","mistake","basic","built","longer","raw","year","give","girl","lion","article","choice","second","softly","greater","safe","poor","out","dug","regular","hold","type","game","again","plan","because","child","instrument","influence"
                    "seldom","season","closer","help","reach","close","beside","tone","locate","queen","harder","bell","among","occur","higher","influence","news","rain","exercise","pleasant","climate","certainly","took","field","extra","every","tobacco","jack","at","inside","bridge","direction","did","magic","can","failed","crew","built","stomach","smile","pen","wolf","poetry","birds","eye","easy","fat","powerful","strong","perfectly","its","unit","having","alive","feathers","happily","notice","whose","pipe","softly","suppose","wonderful","consonant","fear","around","quick","smell","radio","forth","or","row","people","worse","research","wash","giant","baseball","species","steady","ready","rhythm","recent","length","attempt","broke","every","close","prove","write","dirty","pilot","around","industrial","mistake","bow","funny","mail","itself","chicken","ability","society","pain","question","easily","simple","brother","come","quarter","tide","mind","faster","kill","heavy","count","typical","zero","variety","school","week","seeing","couple","effort","secret","quite","consist","greatly","bus","shaking","silly","time","brass","about","leaving","think","fireplace","income","jungle","wonder","away","develop","into","shelf","idea","all","theory","disappear","military","smooth","begun","electricity","establish","desk","industry","identity","supper","kept","near","mother","melted","worker","construction","window","atmosphere","using","castle","support","market","supply","smooth","medicine","own","smell","swimming","become","deeply","attempt","grew","knowledge","service","asleep","desk","income","salt","kill","experience","shop","rays","handle","larger","detail","milk","liquid","had"
                    "yourself","hollow","doubt","education","milk","bush","pen","eager","whenever","quietly","remember","tin","plan","troops","earn","diagram","powder","gain","lower","married","yet","tobacco","captain","would","off","replied","chain","reach","famous","railroad","needs","connected","evidence","cutting","wind","best","shake","against","rain","strike","buffalo","method","police","energy","pile","mixture","quite","dear","dot","desk","fox","verb","trail","agree","pack","of","control","matter","cloth","combination","lungs","column","look","stay","carry","talk","wash","slip","rain","accurate","steady","whole","joy","below","two","arrangement","load","fellow","feel","team","coal","aware","telephone","ill","signal","unusual","weigh","select","brave","island","bring","aboard","excitement","remove","happily","whether","fall","back","typical","eight","fur","ten","half","found","word","subject","cotton","energy","became","word","easier","powerful","army","correctly","scientific","twice","rough","getting","neck","roof","having","tube","disease","tiny","rocky","ask","industrial","together","tomorrow","community","known","baseball","my","night","bell","shadow","shot","change","mood","smaller","wall","shine","further","copy","pick","height","period","after","height","repeat","suppose","seems","chicken","bet","note","eventually","prepare","ready","excellent","length","cage","hair","well","fairly","lower","end","pig","include","camera","environment","fairly","corn","wooden","said","expression","happened","whole","bet","slipped","mean","unhappy","browserling","carefully","another","mirror","engine","mill","choose","tiny","difficulty","western","bowl","war"
                    "silk","between","include","must","try","ship","after","within","meat","saved","bean","paper","fall","church","solve","suddenly","mark","coach","deeply","dream","west","station","he","below","scene","return","yellow","tree","official","addition","couple","police","motion","uncle","effort","halfway","song","strength","studying","trap","leg","win","fallen","whale","inside","mood","trail","stood","village","activity","fourth","bean","were","pain","swam","still","trick","bar","fun","us","sudden","soil","sky","four","in","ball","parent","whom","sold","palace","central","interior","pick","square","loose","hope","riding","section","string","plates","spent","clay","tent","master","dinner","season","fact","per","property","rather","science","gray","series","dollar","back","certain","sort","close","your","asleep","mass","exciting","window","tape","whatever","captain","company","event","pack","small","branch","mountain","improve","habit","stiff","actual","clothes","ground","apartment","title","stared","bell","location","spider","volume","progress","cell","smaller","harbor","point","dinner","death","dull","contain","growth","service","goose","society","forty","natural","duty","completely","third","future","satisfied","ill","pain","television","pipe","percent","planet","traffic","stomach","cutting","right","stand","syllable","produce","exercise","egg","hair","scared","using","managed","blanket","cabin","lunch","become","simple","tune","audience","deal","mile","wild","was","discuss","bicycle","stage","syllable","busy","warn","asleep","suddenly","frequently","count","space","buy","material","wrote","fort","tax","bear","thread"
                    "occur","rocky","eager","does","globe","typical","most","running","quickly","tank","do","manner","customs","neck","excited","upper","influence","compare","globe","different","bill","sit","pleasure","church","live","war","red","stomach","arrive","either","courage","beat","crew","exclaimed","seems","sent","dig","result","research","contrast","sometime","joined","luck","advice","watch","home","grabbed","salmon","port","bill","sit","spell","fireplace","over","corner","replied","fur","porch","public","men","shelter","vertical","becoming","worried","young","very","felt","replace","huge","lovely","climb","thus","stopped","close","bend","both","exciting","bow","seldom","satellites","till","clear","another","frame","coffee","course","daily","picture","ocean","pass","selection","piece","result","chest","show","therefore","newspaper","above","parent","why","mood","thrown","silk","read","series","told","thin","shake","swept","test","ability","library","news","blew","consider","positive","engineer","short","appropriate","characteristic","dried","pen","lying","castle","structure","weak","tip","depend","born","dear","blanket","film","stronger","fighting","gather","division","likely","charge","blanket","ate","mill","start","important","machinery","trunk","run","supper","verb","death","exchange","clearly","opportunity","breath","shop","habit","hollow","sheet","horn","nails","trace","use","voice","beauty","sail","various","stepped","further","figure","wrote","form","since","unless","able","lost","worth","plate","pet","tobacco","father","handsome","fifty","typical","universe","father","grown","she","image","human","shop","indicate","mysterious","dug","nature"
                    "getting","chemical","good","five","well","put","clear","name","president","standard","higher","given","lion","library","differ","act","shelter","honor","frozen","wonderful","clearly","many","moment","usually","family","applied","farther","eye","fence","floor","smell","rays","cat","ten","swing","there","fifty","flies","depth","hollow","idea","planning","forget","salt","build","fox","girl","dirt","finish","stiff","center","known","careful","actual","hearing","on","light","mirror","guard","canal","sign","joy","radio","joined","wise","make","least","lost","doubt","some","told","swimming","down","stomach","however","enough","make","swimming","crop","some","little","longer","shape","burn","get","cold","terrible","probably","produce","riding","rays","here","tax","suddenly","waste","everywhere","old","mental","sheep","elephant","vast","off","leader","settlers","syllable","sell","original","total","advice","cookies","understanding","wherever","than","stay","per","breeze","recall","sky","thrown","vessels","at","hurt","clothes","bet","location","course","several","tide","nodded","saw","sweet","limited","after","local","moon","climb","brought","pour","strip","supper","held","joy","driver","improve","tube","while","crowd","rush","select","colony","equally","lie","lesson","control","came","movement","been","general","far","shoulder","pair","brick","captain","wish","lunch","anything","congress","related","sink","particularly","worker","organized","surface","typical","prize","information","basis","corner","purpose","within","industrial","announced","alike","immediately","provide","corner","think","should","low","missing","frighten","easily","myself"
                    "accurate","announced","stop","measure","chose","simplest","pie","guide","has","relationship","zoo","folks","disease","affect","flew","without","compound","different","cage","track","plate","decide","thee","record","allow","leather","force","shore","canal","done","original","sound","thee","birth","ability","strange","lake","nature","sent","bark","rule","refer","honor","practice","establish","fed","deeply","tube","adjective","place","when","around","paper","massage","identity","especially","entirely","stiff","behavior","same","furniture","knife","gentle","row","fire","am","dirty","carbon","locate","once","per","accident","scientific","rough","social","has","throughout","touch","require","lie","snake","detail","find","share","screen","did","lead","island","fun","safety","appearance","layers","there","machinery","knife","raise","stuck","hair","prize","everywhere","plane","vote","soon","cup","develop","troops","continent","agree","edge","understanding","opposite","group","setting","metal","clear","movie","attached","setting","agree","hung","worried","truth","appropriate","speed","adventure","putting","village","escape","pull","worth","dangerous","bound","research","war","student","pen","aboard","daughter","summer","acres","dark","gift","melted","film","development","alive","graph","fought","steady","quick","then","or","basis","satellites","between","further","everything","eventually","owner","man","steam","orange","quick","belong","beside","disappear","animal","clearly","needed","once","nation","fresh","wheat","chicken","its","spent","brush","either","everybody","biggest","liquid","suggest","wagon","whale","stomach","receive","frequently","return","usually","layers","excitement","carbon","but"
                    "gravity","facing","giant","dot","picture","addition","beneath","know","sink","fuel","being","mistake","due","paint","pleasant","ill","can","teach","sink","average","hat","everybody","scientist","aware","many","roof","fast","nearby","party","account","college","fat","tightly","package","warm","key","blue","constantly","brother","shadow","about","tank","sky","stems","conversation","thrown","smaller","building","plane","depend","wealth","owner","store","highest","attached","percent","steep","nest","spider","not","cut","declared","carbon","port","electric","charge","wood","tape","guide","doll","poor","bean","move","eager","definition","roar","copy","buy","stairs","gate","recognize","useful","composed","wealth","belong","involved","shine","clean","bone","enter","better","increase","diagram","carried","belt","fully","fox","composed","lose","born","sail","tales","aside","his","love","silly","yard","plan","likely","happily","crew","cutting","press","best","railroad","somewhere","poetry","dead","bet","ought","steady","living","appearance","substance","frame","perfectly","aware","lion","visitor","wrapped","paper","meat","spite","apart","house","special","hungry","product","standard","pass","bone","but","stems","roll","lack","grabbed","pure","shade","fear","order","slow","difficulty","powder","easier","needle","mouse","be","depth","quietly","thought","activity","told","pencil","boat","connected","snow","catch","carry","result","wonderful","anyway","reason","shown","dry","pupil","new","introduced","farm","perfect","idea","higher","activity","hand","cloud","these","elephant","percent","unhappy","model","being","repeat","bean","direction"
                    "factor","correctly","movement","needed","invented","variety","perhaps","those","arrange","aside","short","term","full","greater","long","wing","search","desk","collect","green","conversation","group","fully","avoid","diagram","too","cross","satellites","correctly","vegetable","children","fell","represent","trick","finally","shorter","column","themselves","review","cool","do","plane","middle","speech","dust","zoo","aloud","goes","living","sale","available","rays","alphabet","fellow","port","about","angry","question","wheel","birthday","slabs","rear","gather","horn","shown","cell","magic","massage","born","mostly","rising","scared","grow","boy","center","naturally","rice","rhyme","along","impossible","speech","exchange","women","per","nation","attached","morning","sing","kitchen","season","doll","result","honor","hall","music","push","remove","mountain","neighborhood","related","could","ahead","fruit","television","realize","salt","dangerous","salmon","property","feathers","anyone","political","explanation","deeply","sang","anywhere","circle","until","row","living","power","eat","earn","of","military","arrange","rocket","typical","pictured","bit","nearest","manufacturing","blew","herd","peace","excellent","enter","both","wash","between","cannot","familiar","rabbit","creature","lucky","aloud","edge","progress","water","fifty","youth","history","map","arrange","purpose","under","tune","share","usually","drink","everywhere","tell","railroad","bar","brass","give","ask","several","glass","wherever","teach","electricity","classroom","learn","success","coal","game","wonder","pictured","remain","world","tent","ordinary","party","which","flame","difficulty","belong","silent","vote","smoke","except","slow"
                    "telephone","poet","already","stay","live","brief","mark","gain","needed","found","end","nobody","rod","charge","answer","fed","seems","mainly","gray","history","block","point","free","throat","key","factor","held","daily","lonely","specific","cat","spend","principal","strength","equipment","plan","peace","we","paint","flag","swam","cry","sea","feet","ants","earth","join","sat","actually","tone","prepare","mother","ruler","unknown","trick","size","political","riding","brass","aside","which","period","recognize","exclaimed","passage","foreign","tonight","small","alive","bare","laugh","happened","meal","asleep","greater","upward","flies","middle","faster","safety","this","drawn","load","sun","burst","adjective","crowd","cover","pass","class","bush","below","hard","that","built","model","melted","rhythm","where","tower","are","simple","community","love","slide","smoke","bad","soil","young","football","actual","differ","town","death","event","noted","wrapped","weigh","harbor","bat","doing","enjoy","eager","command","will","claws","attached","simplest","mad","rubbed","long","current","sitting","movie","rather","activity","press","hot","necessary","theory","huge","letter","ran","instance","pilot","definition","quietly","aside","continued","explore","pool","music","audience","empty","tribe","tone","little","own","only","pupil","compass","anyway","pink","notice","thou","she","closely","castle","board","second","rice","gradually","feet","wish","wear","am","religious","willing","salmon","railroad","can","brass","corn","independent","bit","break","wait","southern","left","soldier","out","dirt","pass"
                    "yesterday","already","union","handle","sign","us","year","consider","did","work","thread","herself","forty","am","announced","during","before","rubber","courage","write","popular","breathe","direction","wife","typical","organized","identity","anything","biggest","contrast","bush","birth","felt","dug","scared","join","doctor","corner","giving","research","production","ice","desert","among","nodded","frog","notice","play","pack","next","secret","construction","society","several","rod","farm","goes","wing","ourselves","cotton","pretty","independent","sport","verb","principle","missing","spend","cave","stomach","torn","pure","native","uncle","explain","football","slide","sudden","agree","nobody","someone","measure","taste","upon","story","cap","direct","complex","desk","moment","garden","engine","crop","lungs","worth","island","introduced","many","depend","changing","system","so","place","quietly","shirt","very","river","lift","habit","rhythm","fruit","saddle","thirty","sharp","arrow","pass","world","rod","burst","rough","happen","police","keep","settlers","canal","interior","bare","girl","train","clock","syllable","recently","mouse","fully","smoke","wide","quite","moment","noun","lunch","hot","let","extra","clothing","three","trace","upper","burst","report","goose","scientific","community","understanding","gasoline","wife","unit","purpose","check","cat","skin","railroad","everything","whether","wild","this","wise","sale","gravity","amount","memory","arm","everyone","swam","pleasure","oldest","settle","ship","everywhere","pay","spite","control","stick","reason","driving","few","stage","wind","building","animal","taste","whispered","gulf","porch","practical"
                    "element","our","cream","she","truck","certainly","ice","sentence","paper","fallen","gate","sand","struck","hit","aside","smile","grass","torn","smoke","circle","cookies","magic","sent","pine","earth","wheel","gone","frame","language","reason","certain","she","found","compound","indicate","cup","move","time","run","tightly","does","deep","age","city","gift","capital","sum","putting","six","amount","any","knowledge","living","few","butter","winter","level","baby","position","bound","vote","control","everybody","spider","stairs","speech","exercise","point","month","east","mass","aid","disappear","themselves","box","foreign","involved","grass","dead","animal","action","social","road","sea","these","shown","more","check","fish","planning","wealth","cap","vast","weak","smallest","spent","one","hollow","traffic","remain","explore","better","death","select","toward","loose","lamp","shine","fighting","calm","rubber","gift","loud","cattle","corner","station","egg","forgot","sense","century","person","heard","thank","government","introduced","scene","knife","throughout","us","row","student","order","eaten","forth","frequently","its","guard","bee","be","fruit","favorite","play","race","must","constantly","valley","white","typical","magnet","rough","class","rice","least","free","food","bright","worry","chosen","reader","tight","lucky","range","ancient","film","soon","earn","ate","friend","plane","excellent","tall","bet","underline","birth","thy","contrast","whether","actual","canal","finger","green","total","forget","driver","phrase","nearby","court","unhappy","asleep","office","mean","sent","locate"
                    "gather","half","material","connected","well","plus","drew","acres","stranger","impossible","throat","police","any","thick","test","range","copper","because","wolf","coffee","pipe","reach","until","arrangement","energy","whose","wise","gain","order","medicine","frozen","blow","ago","tall","support","duck","bite","ought","anywhere","ten","trail","liquid","health","port","huge","familiar","pan","skin","ever","chart","badly","lie","sun","spring","journey","refused","raise","myself","burst","darkness","result","in","information","train","married","property","board","people","well","laugh","stand","too","select","cheese","kind","straw","basis","wheel","mud","honor","principal","member","age","region","education","quarter","tropical","learn","luck","nobody","education","slope","mostly","key","purple","afraid","bare","great","needed","upon","remove","mass","tonight","factory","between","fair","dinner","vapor","somebody","same","police","mixture","shine","thin","hung","willing","location","prize","accept","musical","popular","period","tip","claws","depend","extra","development","special","upward","milk","about","fallen","island","animal","ought","more","mail","eight","cook","wrong","wherever","moving","rod","sitting","article","rice","copper","roar","night","early","easier","factor","zoo","including","basis","up","mix","direct","ear","care","catch","am","path","engineer","doll","religious","statement","these","water","blank","stop","grade","center","fairly","height","aside","stand","cross","disappear","grandfather","about","above","taught","fallen","able","plane","special","musical","directly","am","each","lucky","substance"
                    "follow","income","slip","potatoes","nobody","color","review","town","organization","search","store","later","spent","kept","water","top","back","pass","dozen","lower","small","hide","yellow","furniture","shine","origin","saved","serious","nest","ate","pink","whole","feel","quickly","joined","sudden","canal","course","tube","perhaps","bright","teeth","camp","choice","point","do","life","foreign","musical","direction","mad","plates","review","hole","wife","case","root","oxygen","became","contrast","plant","fifth","threw","now","bag","immediately","eye","tall","plain","living","shot","bigger","village","wolf","camp","month","chemical","do","beauty","studied","world","cap","shine","remain","ever","thumb","needs","freedom","every","break","calm","easily","if","length","country","sudden","between","fear","people","society","particularly","pilot","gas","sang","fruit","refused","ill","fierce","throat","protection","children","setting","your","instrument","failed","away","continent","solid","muscle","just","of","express","clear","field","whom","greater","wonder","quarter","large","extra","shallow","earlier","afternoon","equipment","arrange","name","spend","safe","except","spring","pass","he","mouse","dinner","football","present","stream","itself","basis","taught","scared","face","tales","possible","scene","too","note","like","wonderful","lake","jungle","name","difference","completely","doctor","military","garden","star","buffalo","tree","wet","fat","shorter","fly","sign","anything","year","earlier","lesson","train","people","raise","win","general","member","whale","east","broken","voice","composition","me","wise","necessary"
                    "declared","industrial","wonderful","hunter","sheet","win","sunlight","she","compound","important","held","equally","boat","differ","hollow","enjoy","older","tent","local","music","giving","musical","no","individual","giving","floating","whispered","blow","smoke","examine","five","bowl","composition","unusual","greatest","solar","apartment","continued","younger","field","construction","bow","radio","mixture","spent","smell","language","rate","planned","atmosphere","attempt","plant","find","so","row","captain","finish","part","have","herd","automobile","hit","certainly","rate","replace","certainly","garage","notice","explain","hang","picture","arrow","fed","largest","lungs","wild","union","main","trace","partly","play","pan","agree","him","level","tears","trace","best","if","edge","nest","nobody","temperature","has","shoot","suggest","nest","itself","chicken","cow","globe","great","division","once","dropped","seeing","part","slight","score","closely","show","watch","was","dawn","spend","worth","lunch","nine","fewer","wood","creature","has","division","certain","top","square","first","free","layers","has","flies","film","pie","hole","ever","single","strength","choice","complete","move","discussion","spite","east","local","gun","spider","already","engineer","straw","whose","battle","dried","member","addition","produce","loud","shadow","constantly","mixture","shinning","private","broke","properly","bright","breath","lead","mainly","act","necessary","were","apart","badly","burst","replied","compound","cave","means","mood","down","chief","taste","tie","nest","hurried","come","example","cell","floor","political","eleven","driver","fear","invented"
                    "complete","gradually","salmon","expect","deal","browserling","ear","select","exchange","jet","door","stand","mean","stiff","dress","distant","heading","book","till","friend","grandfather","orange","four","handsome","middle","torn","comfortable","personal","park","shoot","cook","press","wave","massage","escape","deep","west","catch","write","hearing","chart","were","thirty","blue","behind","condition","world","dull","fat","sharp","feature","gain","though","effect","industry","begun","college","truck","identity","thought","condition","mean","station","than","cent","life","action","worse","refer","upward","apple","fully","several","beautiful","very","apple","courage","diagram","section","merely","window","angle","thin","son","scale","brought","mill","orbit","tail","lose","early","deal","speed","play","ship","ants","general","extra","feature","rabbit","failed","weather","spoken","said","dirt","play","sum","up","element","facing","cow","attempt","short","adult","slow","spend","pen","being","safe","surprise","full","believed","aid","nodded","weak","leather","grew","perhaps","gold","firm","got","apple","rapidly","left","believed","appropriate","morning","climate","orbit","date","greatly","equator","pick","tobacco","original","necessary","species","fat","live","proper","scale","ear","guide","in","low","bean","angle","shore","solar","officer","smooth","image","cutting","seems","solve","upon","dry","carried","earlier","claws","ready","this","problem","wall","bank","comfortable","copper","composition","pictured","newspaper","left","primitive","common","know","another","diagram","gravity","count","high","unless","sun","advice","picture"
                    "electric","buy","planet","low","sink","away","quite","related","valuable","taste","firm","hurry","transportation","history","tropical","do","organization","exactly","selection","kids","pair","elephant","film","by","father","by","capital","information","press","over","wet","hay","thy","history","basic","tape","cannot","sad","than","consist","reader","softly","massage","motor","today","universe","chest","usual","talk","new","treated","speed","consonant","level","cap","tree","triangle","somebody","search","dress","way","station","sell","route","brother","before","harbor","handsome","love","her","sat","slabs","noise","imagine","sing","be","join","among","my","plane","fierce","trunk","studied","broken","average","castle","use","are","seed","walk","cat","aloud","pony","duck","discussion","card","pressure","route","somebody","afternoon","hat","strike","day","office","history","principal","lake","accident","red","adventure","mix","quarter","everybody","date","anyway","harder","sunlight","structure","air","dust","month","city","torn","major","slip","period","crowd","generally","fifty","image","plan","porch","mice","was","dog","telephone","sometime","settle","climate","through","more","largest","such","four","lead","throat","everybody","prevent","found","already","planet","cotton","buy","blood","youth","must","grain","log","fun","frozen","ought","fun","laugh","bottle","discovery","sum","doll","southern","sad","shallow","blow","fifty","cookies","straw","sheep","rabbit","only","remove","such","against","avoid","fallen","explore","motor","proud","operation","pay","becoming","environment","congress","hill","bag","guide"
                    "freedom","mission","additional","eleven","industry","has","gasoline","time","stomach","belt","football","joined","element","connected","along","they","largest","fast","mine","symbol","lesson","sing","found","fuel","title","lot","them","rock","plain","danger","duck","frequently","from","carried","desk","grabbed","daily","two","exclaimed","outline","origin","not","bottom","changing","cause","disease","each","improve","describe","firm","ahead","compound","sold","tube","scared","cave","wire","lonely","fur","fell","construction","taught","ship","nearly","softly","attached","car","help","nearest","garden","wise","slow","atomic","captain","dried","tip","previous","pine","lion","unhappy","size","wolf","comfortable","determine","herself","from","rough","repeat","seeing","dark","including","price","spite","both","one","gift","situation","meal","usually","dried","change","brief","meet","rock","meet","molecular","sell","construction","direct","father","whispered","tall","broken","valuable","pound","band","quickly","perfect","collect","string","arrow","bottom","lonely","fast","stone","leather","rubbed","grass","living","nothing","successful","once","list","army","visit","eaten","studying","come","stock","poet","store","pencil","boat","among","swam","eye","divide","declared","shirt","wire","told","describe","vowel","clear","master","apart","central","lift","smaller","matter","plate","practice","thirty","strange","year","wrapped","feet","environment","street","letter","way","command","stand","how","increase","cotton","easily","face","dull","top","afraid","create","few","mental","nice","walk","somebody","program","go","satisfied","warm","aloud","church"
                    "limited","various","across","softly","stopped","instant","directly","branch","universe","symbol","drove","combine","please","usually","tail","shelf","grow","control","what","produce","gave","club","except","through","rest","human","shadow","fewer","helpful","remember","change","little","correctly","slide","meal","class","off","asleep","seems","swept","ran","when","pine","plenty","statement","provide","even","perfectly","southern","appropriate","measure","straight","breath","skill","tone","aloud","pale","loss","floating","army","broad","safe","wife","morning","next","dollar","attached","writing","careful","pleasure","brush","thin","shut","song","against","clearly","collect","in","receive","large","stranger","cotton","separate","explanation","change","zoo","equally","depend","badly","have","exciting","basic","positive","choose","experiment","electricity","yourself","swept","mathematics","silence","science","helpful","unit","palace","classroom","fall","let","occasionally","happy","nine","broke","treated","inside","freedom","quiet","mighty","show","carried","needs","captured","nest","trap","story","shoe","generally","standard","electricity","cheese","society","boat","brain","maybe","held","pair","cut","if","experiment","so","treated","provide","deer","clean","light","depend","sail","halfway","living","make","circus","might","claws","agree","pot","explain","grass","track","giant","bite","catch","add","anywhere","making","terrible","under","locate","young","take","read","seen","drink","wind","became","rock","gather","typical","football","excellent","birds","part","factor","struggle","from","doubt","pitch","been","dropped","breeze","obtain","develop","built","park","home","wrote"
                    """;

    @Test
    void outputValuesParsing() {
        List<Object> splitAndFormattedOutputValues = new OutputValuesParser().splitAndFormatInputOutputValues(LONG_LIST_OUTPUT_VALUES);

        assertThat(splitAndFormattedOutputValues)
                .hasSize(5761)
                .allMatch(t -> !((String) t).startsWith("\""))
                .allMatch(t -> !((String) t).endsWith("\""));
    }

    @Test
    void outputValuesParsingRegressionStackOverflow() {
        assertThatThrownBy(() -> splitAndFormatInputOutputValues(LONG_LIST_OUTPUT_VALUES))
                .isInstanceOf(StackOverflowError.class);
    }

    @Test
    void regressionOutputValuesParsing() {
        List<Object> splitAndFormattedOutputValuesNew = new OutputValuesParser().splitAndFormatInputOutputValues(LIST_OUTPUT_VALUES);
        List<Object> splitAndFormattedOutputValuesOld = splitAndFormatInputOutputValues(LIST_OUTPUT_VALUES);

        assertThat(splitAndFormattedOutputValuesNew)
                .isEqualTo(splitAndFormattedOutputValuesOld);
    }

    @Test
    void regressionOutputValuesNumbersParsing() {
        List<Object> splitAndFormattedOutputValuesNew = new OutputValuesParser().splitAndFormatInputOutputValues(LIST_OUTPUT_VALUES_NUMBER);
        List<Object> splitAndFormattedOutputValuesOld = splitAndFormatInputOutputValues(LIST_OUTPUT_VALUES_NUMBER);

        assertThat(splitAndFormattedOutputValuesNew)
                .isEqualTo(splitAndFormattedOutputValuesOld);
    }

    protected static List<Object> splitAndFormatInputOutputValues(String outputValuesText) {
        if (StringUtils.isEmpty(outputValuesText)) {
            return Collections.emptyList();
        }

        String[] outputValuesSplit = outputValuesText.replaceAll("^\"", "").split("\"?(,|$)(?=(([^\"]*\"){2})*[^\"]*$) *\"?");
        return new ArrayList<>(Arrays.asList(outputValuesSplit));
    }
}
